python child class call parent method

37

# use the super method:

class Foo(Bar): # the child class
    def baz(self, **kwargs):
        return super().baz(**kwargs)

# For Python < 3, you must explicitly opt in to using new-style classes and use:

class Foo(Bar): # the child class
    def baz(self, arg):
        return super(Foo, self).baz(arg)
        

Comments

Submit
0 Comments